#ifndef DRAGABLE_ITEM_H
#define DRAGABLE_ITEM_H

#include <QObject>
#include <QGraphicsPixmapItem>
#include <QGraphicsSceneHoverEvent>

// 自定义可拖拽的图形项
class DragablePixmapItem :public QObject, public QGraphicsPixmapItem
{
     Q_OBJECT
public:
    explicit DragablePixmapItem(QGraphicsItem *parent = nullptr);
    explicit DragablePixmapItem(const QString& name, QGraphicsItem *parent = nullptr);
    QString name() const;

    // 标记是否已穿戴
    void setWorn(bool worn) ;
    bool isWorn() const ;
signals:
    void positionChanged(DragablePixmapItem* item); // 位置变化信号
    void hovered(bool isHovered); // 悬停信号

protected:
    QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
     void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
     void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
     void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
     void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;

private:
    QString m_name;
    bool m_isWorn; // 标记是否已穿戴到身上
};

#endif // DRAGABLE_ITEM_H
